package com.data.center.dictionary;

import com.data.center.exception.exception.BizException;
import com.data.center.exception.info.CommonEnum;

/**
 * @author DN
 * @description:个人状态代码映射枚举类CD000015
 * @date 2023/11/30 18:00
 */
public enum Status implements KeyValueMap {
    ON_JOB("1", "在职"),
    RETIRED("2", "离退"),
    DECEASED("4", "已去世"),
    OTHER("9", "其他");

    private String code;
    private String name;

    Status(String code, String name) {
        this.code = code;
        this.name = name;
    }

    @Override
    public String getKey() {
        return code;
    }

    @Override
    public String getValue() {
        return name;
    }

    public static Status getValueByKey(String key) {
        for (Status status : values()) {
            if (status.code.equals(key)) {
                return status;
            }
        }
        throw new BizException(CommonEnum.CAN_NOT_FIND_IN_DICTIONARY);
    }

    public static Status getKeyByValue(String value) {
        for (Status status : values()) {
            if (status.name.equals(value)) {
                return status;
            }
        }
        throw new BizException(CommonEnum.CAN_NOT_FIND_IN_DICTIONARY);
    }
}
